package com.java83.listen;

/**
 * @Author lzh
 * @Description
 * @Date 2022/2/23 10:46
 */

import com.java83.config.FenInter;
import com.java83.domain.LzhServiceLog;
import com.java83.mapper.LzhServiceLogMapper;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定义一个Bean，消费者，监听队列，定义处理消息的方法
 */
@Component
public class MyConsumer {
//    @Autowired(required = false)
//    FenInter fenInter;
    @Autowired
    LzhServiceLogMapper lzhServiceLogMapper;
    //指定当前方法监听哪个队列
    @RabbitListener(queues = "tdSX")
    //String msg,   消息体
    //Message message 消息对象
    //com.rabbitmq.client.Channel channel  信道
    public void receiveEmail(LzhServiceLog lzhServiceLog) {
        System.out.println("处理Email");
        if(lzhServiceLog.getStatus().equals("申请阶段")){
            lzhServiceLog.setStatus("已失效");
            lzhServiceLogMapper.updateLzhServiceLog(lzhServiceLog);
        }
    }
}